package a66weding.com.jiehuntong.activity.toolsbudget;

import android.content.Context;
import android.os.Bundle;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.widget.PopupWindow;

import a66weding.com.jiehuntong.R;
import a66weding.com.jiehuntong.application.DataWareHourse;
import a66weding.com.jiehuntong.application.GlobalApplication;
import a66weding.com.jiehuntong.beans.User;
import me.imid.swipebacklayout.lib.app.SwipeBackActivity;

/**
 * @version :
 * @creator : AxDu
 * @create-time : 2016/7/8
 * @description :
 */
public class BaseBudgetActivity extends SwipeBackActivity {
    protected User user;
    public PopupWindow mCommitpop;
    public static int GETPLACERESULTCODE=1;
    public static int GETBUDGETRESULTCODE=2;
    protected int budgetCount;
    protected int tableCount;

    protected static final int HAVEDATA=1;
    protected static final int NODATA=0;
    protected static final int DATAERROR=2;

    protected boolean isshowed;
    protected boolean islogin;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        super.onCreate(savedInstanceState);
        islogin = ((GlobalApplication) getApplication()).isLogin();
        if(islogin) {
            user = DataWareHourse.getInstance().getmUser();

        }

    }


    public void showCommitPopupWindow(Context context, View view) {
        // 一个自定义的布局，作为显示的内容
        View contentView = LayoutInflater.from(context).inflate(
                R.layout.pop_tools_wedregister_commit, null);

        mCommitpop = new PopupWindow(contentView,
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT, true);

        contentView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mCommitpop.dismiss();
            }
        });


        //点击空白处时，隐藏掉pop窗口
        mCommitpop.setTouchable(true);


        mCommitpop.setTouchInterceptor(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {

                return true;
                // 这里如果返回true的话，touch事件将被拦截
            }
        });

        //设置位置
        mCommitpop.showAtLocation(view, Gravity.BOTTOM|Gravity.CENTER_HORIZONTAL,0,0);//设置在屏幕中的显示位置

        // 设置好参数之后再show
        mCommitpop.showAsDropDown(view);

    }

    public boolean isshowed() {
        return isshowed;
    }

    public void setIsshowed(boolean isshowed) {
        this.isshowed = isshowed;
    }

    public int getTableCount() {
        return tableCount;
    }

    public void setTableCount(int tableCount) {
        this.tableCount = tableCount;
    }

    public int getBudgetCount() {
        return budgetCount;
    }

    public void setBudgetCount(int budgetCount) {
        this.budgetCount = budgetCount;
    }
}
